﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Zebra.DataAccess
{
    //Singleton implementation to return the same BooksRepository
    public sealed class Repository
    {
        static UsersRepository _userRepository = null;
        static string connectionString;

        private Repository() { }

        public static void ConnectionString(string cs)
        {
            connectionString = cs;
        }

        public static UsersRepository UserRespository(Boolean create)
        {
            if (connectionString == null)
                throw new ApplicationException("Need to set connection string for Repository");

            if (!create && _userRepository != null)
                return _userRepository;
            else
            {
                _userRepository = new UsersRepository(connectionString);
                return _userRepository;
            }
        }
    }
}
